import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import babel from '@rollup/plugin-babel'
import { modifyVars } from './lessVars'
const path = require('path')

const baseUrl = 'http://shipin.zhichu.tech/'
// const baseUrl = 'http://meetingsec.diac.org.cn/'

function resolve (p) {
  return path.resolve(__dirname, p)
}

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    react(),
    // babel({
    //   presets: [
    //     [
    //       '@babel/preset-env',
    //       { corejs: 2, useBuiltIns: 'usage', targets: { ie: '11' } }
    //     ]
    //   ]
    // })
  ],
  server: {
    proxy: {
      '/api/': {
        target: baseUrl,
        changeOrigin: true
      },
      '/upload/': {
        target: baseUrl,
        changeOrigin: true
      },
      '/uploads/': {
        target: baseUrl,
        changeOrigin: true
      }
    }
  },
  resolve: {
    alias: {
      '@src': resolve('src'),
      '@js': resolve('src/assets/js'),
      '@imgs': resolve('src/assets/imgs'),
      '@redux': resolve('src/redux'),
      '@router': resolve('src/router'),
      '@components': resolve('src/components'),
      '@pages': resolve('src/pages')
    }
  },
  css: {
    preprocessorOptions: {
      less: {
        modifyVars,
        javascriptEnabled: true
      }
    }
  },
})


